/* eslint valid-jsdoc: "off" */

/**
 * @param {Egg.EggAppInfo} appInfo app info
 */
module.exports = appInfo => {
	/**
	 * built-in config
	 * @type {Egg.EggAppConfig}
	 **/
	const config = (exports = {});

	// 解决跨域
	config.cors = {
		origin: "*",
		allowMethods: "GET,HEAD,PUT,POST,DELETE,PATCH"
	};

	config.security = {
		csrf: {
			useSession: false,
			enable: false,
			ignoreJSON: false,
			cookieName: "csrfToken",
			sessionName: "csrfToken",
			headerName: "x-csrf-token",
			bodyName: "_csrf",
			queryName: "_csrf"
		},
		domainWhiteList: ["http://localhost:7001"]
	};

	// use for cookie sign key, should change to your own and keep security
	config.keys = appInfo.name + "_1714110145703_7471";

	// add your middleware config here
	config.middleware = [];

	// add your user config here
	const userConfig = {
		// myAppName: 'egg',
	};

	config.mysql = {
		client: {
			// host
			host: "localhost",
			// 端口号
			port: "3306",
			// 用户名
			user: "root",
			// 密码
			password: "123456",
			// 数据库名
			database: "trade"
		},
		// 是否加载到 app 上，默认开启
		app: true,
		// 是否加载到 agent 上，默认关闭
		agent: false
	};

	config.jwt = {
		secret: "trade",
		enable: true, 
	};

	return {
		...config,
		...userConfig
	};
};
